/*
 * @Author: silence
 * @Date: 2023-07-04 15:09:02
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-11-08 13:21:23
 * @Description: 电站详情
 */
import 'package:ems_neutral_app/base/SilScaffold.dart';
import 'package:ems_neutral_app/common/widgets/cubitWidget/DividingLine.dart';
import 'package:ems_neutral_app/pages/PowerStation/Controller/PowerStationDetailController.dart';
import 'package:ems_neutral_app/utils/color/ColorUtils.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sil_base_widget_package/sil_base_widget_package.dart';

import '../../../entities/PowerStationEntity.dart';
import 'PsDetailBaseInfoView.dart';
import 'PsDetailEnergyChartView.dart';
import 'PsDetailRealTimeView.dart';
import 'PsDetailSocChartView.dart';

class PowerStationDetailPage extends StatefulWidget {
  final PowerStationEntity powerStationEntity;
  const PowerStationDetailPage({required this.powerStationEntity, super.key});

  @override
  State<PowerStationDetailPage> createState() => _PowerStationDetailPageState();
}

class _PowerStationDetailPageState extends State<PowerStationDetailPage> {
  PowerStationDetailController _controller =
      Get.put(PowerStationDetailController());

  @override
  void initState() {
    super.initState();
    getData();
  }

  getData() {
    _controller.powerStationBaseDetail(
        context: context, sourceEntity: widget.powerStationEntity);
  }

  @override
  Widget build(BuildContext context) {
    return SilScaffold(
      sideMargin: 0,
      stateBarHide: true,
      navBarHide: true,
      backgroundColor: Colors.black,
      body: mainWidget(),
    );
  }

  mainWidget() {
    return CustomScrollView(
      slivers: [
        /// 基础信息
        SliverToBoxAdapter(child: PsDetailBaseInfoView()),

        /// 实时数据，暂时隐藏掉
        // /// 高压机型 显示实时数据
        // if (_controller
        //         .powerStationEntity.value.equipmentSelection ==
        //     '1')
        //   SliverToBoxAdapter(child: PsDetailRealTimeView()),

        // /// 高压机型 显示实时数据分割线
        // if (_controller
        //         .powerStationEntity.value.equipmentSelection ==
        //     '1')
        //   SliverToBoxAdapter(
        //       child: DividingLine(
        //     margin: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.w),
        //     color: ColorUtils.hexColor('#4a4a4a'),
        //   )),

        /// 发电量/用电量
        SliverToBoxAdapter(child: PsDetailEnergyChartView()),

        SliverToBoxAdapter(
            child: DividingLine(
          margin: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.w),
          color: ColorUtils.hexColor('#4a4a4a'),
        )),

        /// 实时SOC(电池百分比曲线)
        SliverToBoxAdapter(
          child: PsDetailSocChartView(),
        )
      ],
    );
  }
}
